home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Other Langs / abc / examples / advent / advent.ftp next >
Encoding:
Text File  |  1994-04-01  |  9.4 KB  |  279 lines  |  [TEXT/R*ch]

  1. HOW TO A CHECK:
  2.    SHARE map, description, start.objects
  3.    PUT "" IN more
  4.    PUT (keys map)union(keys start.objects) IN places
  5.    FOR mapping IN map:
  6.       PUT places union mapping IN places
  7.    FOR place IN places:
  8.       IF place not.in keys map:
  9.          A MAP place
  10.          PUT "yes" IN more
  11.       IF place not.in keys description:
  12.          A DESCRIBE place
  13.          PUT "yes" IN more
  14.    FOR place IN keys start.objects:
  15.       FOR object IN start.objects[place]:
  16.          IF object not.in keys description:
  17.             A DESCRIBE object
  18.             PUT "yes" IN more
  19.    IF more <> "": A CHECK
  20.  
  21. HOW TO A DELETE place:
  22.    SHARE map, description
  23.    IF place in keys description:
  24.       DELETE description[place]
  25.    IF place in keys map:
  26.       DELETE map[place]
  27.    FOR p IN keys map:
  28.       FOR d IN keys map[p]:
  29.          IF map[p][d] = place:
  30.             DELETE map[p][d]
  31.             IF map[p] = {}:
  32.                DELETE map[p]
  33.  
  34. HOW TO A DESCRIBE place:
  35.    SHARE description
  36.    IF place in keys description:
  37.       WRITE "Already described" /
  38.       QUIT
  39.    WRITE "Describe ", place, ":" /
  40.    A FILL description[place]
  41.  
  42. HOW TO A FILL message:
  43.    PUT {} IN message
  44.    PROMPT '> ' FOR line
  45.    WHILE line <> ".":
  46.       PUT line IN message[#message+1]
  47.       PROMPT '> ' FOR line
  48.  
  49. HOW TO A MAP place:
  50.    SHARE map
  51.    WRITE "Map `place`:" /
  52.    IF place not.in keys map:
  53.       PUT {} IN map[place]
  54.    PROMPT "dirn: " FOR dir
  55.    WHILE dir <> "":
  56.       SELECT:
  57.          dir = "?":
  58.             WRITE ", " listed all.places /
  59.          ELSE:
  60.             PROMPT 'to: ' FOR to
  61.             IF to <> "":
  62.                PUT to IN map[place][dir]
  63.       PROMPT "dirn: " FOR dir
  64.  
  65. HOW TO A SHOW MAP:
  66.    SHARE map
  67.    FOR k IN keys map:
  68.       WRITE k, ": "/
  69.       FOR dir IN keys map[k]:
  70.          WRITE '   ', dir, '->', map[k][dir] /
  71.  
  72. HOW TO A SYNONYM:
  73.    SHARE synonyms
  74.    PROMPT 'original word: ' FOR word
  75.    WHILE word <> "":
  76.       IF word not.in keys synonyms: PUT {} IN synonyms[word]
  77.       PROMPT 'syn: ' FOR syn
  78.       WHILE syn <> "":
  79.          IF syn not.in synonyms[word]:
  80.             INSERT syn IN synonyms[word]
  81.          PROMPT 'syn: ' FOR syn
  82.       PROMPT 'original word: ' FOR word
  83.  
  84. HOW TO ADVENTURE:
  85.    START
  86.    GET command
  87.    WHILE command <> "quit":
  88.       OBEY command
  89.       GET command
  90.    FINISH
  91.  
  92. HOW TO CAN'T DO verb, object:
  93.    WRITE "I can't do that!" /
  94.  
  95. HOW TO DESCRIBE place:
  96.    SHARE description, visited, objects
  97.    SELECT:
  98.       place in visited: WRITE "You're `place`." /
  99.       ELSE:
  100.          DISPLAY description[place]
  101.          INSERT place IN visited
  102.    FOR object IN objects for place:
  103.       DISPLAY description[object]
  104.  
  105. HOW TO DISPLAY message:
  106.    FOR line IN message:
  107.       WRITE line /
  108.  
  109. HOW TO DROP object:
  110.    SHARE holding, objects, place
  111.    REMOVE object FROM holding
  112.    INCLUDE object IN objects FOR place
  113.  
  114. HOW TO FINISH:
  115.    WRITE "Bye" /
  116.  
  117. HOW TO GET command:
  118.    GET LINE
  119.    WHILE command = "": GET LINE
  120. GET LINE:
  121.    WRITE '> '
  122.    READ command RAW
  123.    PUT lower stripped command IN command
  124.  
  125. HOW TO INCLUDE object IN property FOR thing:
  126.    IF thing not.in keys property:
  127.       PUT {} IN property[thing]
  128.    INSERT object IN property[thing]
  129.  
  130. HOW TO INVENTORY:
  131.    SHARE holding
  132.    WRITE "You are carrying: ", " " listed holding /
  133.  
  134. HOW TO LOOK object:
  135.    SHARE visited, place
  136.    SELECT:
  137.       object = "":
  138.          REMOVE place FROM visited
  139.          DESCRIBE place
  140.       ELSE:
  141.          WRITE "I can't." /
  142.  
  143. HOW TO MOVE TO there:
  144.    SHARE place
  145.    PUT there IN place
  146.    DESCRIBE place
  147.  
  148. HOW TO OBEY command:
  149.    SPLIT command INTO verb AND object
  150.    SELECT:
  151.       verb = "": PASS
  152.       special command: TRY TO MOVE command
  153.       verb = "move": TRY TO MOVE object
  154.       verb = "take": TRY TO TAKE object
  155.       verb = "drop": TRY TO DROP object
  156.       verb = "kill": TRY TO KILL object
  157.       verb = "what": INVENTORY
  158.       verb = "look": LOOK object
  159.       ELSE: CAN'T DO verb, object
  160.  
  161. HOW TO PROMPT p FOR line:
  162.    WRITE p
  163.    READ line RAW
  164.  
  165. HOW TO SPLIT command INTO verb AND object:
  166.    SHARE synonyms
  167.    PUT synonym command IN command
  168.    PUT split command IN words
  169.    SELECT:
  170.       #words = 1: PUT words item 1, "" IN verb, object
  171.       #words = 2: PUT words item 1, words item 2 IN verb, object
  172.       ELSE:
  173.          WRITE "Please use 1 or 2 word sentences." /
  174.          PUT "", "" IN verb, object
  175.    PUT synonym verb IN verb
  176.  
  177. HOW TO START:
  178.    SHARE place, start.objects, objects, holding, visited
  179.    PUT "outside the building" IN place
  180.    PUT start.objects IN objects
  181.    PUT {} IN holding
  182.    PUT {} IN visited
  183.    DESCRIBE place
  184.  
  185. HOW TO TAKE object:
  186.    SHARE holding, objects, place
  187.    REMOVE object FROM objects[place]
  188.    INSERT object IN holding
  189.  
  190. HOW TO TRY TO DROP object:
  191.    SELECT:
  192.       object = "": WRITE "Which object?" /
  193.       NOT carrying object: WRITE "You're not carrying it!" /
  194.       ELSE: DROP object
  195.  
  196. HOW TO TRY TO KILL object:
  197.    WRITE "Try to kill", object /
  198.  
  199. HOW TO TRY TO MOVE direction:
  200.    SHARE map, place
  201.    SELECT:
  202.       direction = "":
  203.          WRITE "Where to?" /
  204.       direction in keys map[place]:
  205.          MOVE TO map[place][direction]
  206.       ELSE:
  207.          WRITE "You don't seem to be able to go that way" /
  208.  
  209. HOW TO TRY TO TAKE object:
  210.    SHARE holding
  211.    SELECT:
  212.       object = "":
  213.          WRITE "Which object?" /
  214.       carrying object:
  215.          WRITE "You're already carrying it!" /
  216.       NOT present object:
  217.          WRITE "I see no `object`." /
  218.       #holding > 6:
  219.          WRITE "You can't carry any more." /
  220.       ELSE:
  221.          TAKE object
  222.  
  223. HOW TO RETURN all.places:
  224.    SHARE map
  225.    PUT keys map IN places
  226.    FOR mapping IN map:
  227.       PUT places union mapping IN places
  228.    RETURN places
  229.  
  230. HOW TO RETURN synonym verb:
  231.    SHARE synonyms
  232.    IF SOME word IN keys synonyms HAS verb in synonyms[word]:
  233.       RETURN word
  234.    RETURN verb
  235.  
  236. HOW TO RETURN property for thing:
  237.    SELECT:
  238.       thing in keys property: RETURN property[thing]
  239.       ELSE: RETURN {}
  240.  
  241. HOW TO RETURN a less b:
  242.    FOR x IN b:
  243.       IF x in a:
  244.          REMOVE x FROM a
  245.    RETURN a
  246.  
  247. HOW TO RETURN sep listed things:
  248.    PUT "", "" IN list, s
  249.    FOR thing IN things:
  250.       PUT list^s^(thing<<1), sep IN list, s
  251.    RETURN list
  252.  
  253. HOW TO RETURN a union b:
  254.    FOR x IN b:
  255.       IF x not.in a:
  256.          INSERT x IN a
  257.    RETURN a
  258.  
  259. HOW TO REPORT carrying object:
  260.    SHARE holding
  261.    REPORT object in holding
  262.  
  263. HOW TO REPORT present object:
  264.    SHARE objects, place
  265.    REPORT object in objects for place
  266.  
  267. HOW TO REPORT special command:
  268.    SHARE map, place
  269.    REPORT command in keys map[place]
  270.  
  271. PUT {["at the grate"]:{[1]:"You are by a small metal grate fixed into the ground."};["at the open grate"]:{[1]:"You are at a hole in the ground."};["at the small slit"]:{[1]:"You are at a small slit that the river runs down.";[2]:"A dry river bed carries on ahead."};["at the top of the stairs"]:{[1]:"You are at the top of some stairs.";[2]:"Thin whispy mist comes up the stairs from below."};["bird"]:{[1]:"There is a bird here, happily singing."};["cage"]:{[1]:"There is a cage here."};["grate"]:{[1]:"There is a metal grate here."};["in the bird chamber"]:{[1]:"You are in a dark chamber."};["in the dim chamber"]:{[1]:"You are in a dim chamber.";[2]:"To the east glows a dim light.";[3]:"There is an exit to the west."};["in the forest"]:{[1]:"You are in the forest. There are trees all around."};["in the hole"]:{[1]:"You are in a hole dug in the ground.";[2]:"Above you, you can see blue sky.";[3]:"A dark tunnel exits to the west."};["inside large hall"]:{[1]:"This is a large hall.";[2]:"There are exits in all directions."};["inside the building"]:{[1]:"You are inside a building, the well house for a spring."};["keys"]:{[1]:"There are some keys here."};["outside the building"]:{[1]:"You are standing by a building at the end of a road.";[2]:"A spring flows from the building."};["standing by the stream"]:{[1]:"You are standing by a stream."}} IN description
  272. PUT {} IN holding
  273. PUT {["at the grate"]:{["north"]:"at the small slit";["open grate"]:"at the open grate"};["at the open grate"]:{["down"]:"in the hole";["north"]:"at the small slit"};["at the small slit"]:{["north"]:"standing by the stream";["south"]:"at the grate"};["at the top of the stairs"]:{["down"]:"inside large hall";["east"]:"in the bird chamber"};["in alcove"]:{["out"]:"in the hall"};["in the bird chamber"]:{["east"]:"in the dim chamber";["west"]:"at the top of the stairs"};["in the dim chamber"]:{["east"]:"in the hole";["west"]:"in the bird chamber"};["in the forest"]:{["east"]:"in the forest";["north"]:"in the forest";["south"]:"in the forest";["west"]:"standing by the stream"};["in the hall"]:{["west"]:"in alcove"};["in the hole"]:{["up"]:"at the open grate";["west"]:"in the dim chamber"};["inside large hall"]:{["up"]:"at the top of the stairs"};["inside the building"]:{["out"]:"outside the building"};["outside the building"]:{["in"]:"inside the building";["south"]:"standing by the stream";["west"]:"in the forest"};["standing by the stream"]:{["east"]:"in the forest";["north"]:"outside the building";["south"]:"at the small slit";["west"]:"in the forest"}} IN map
  274. PUT {["at the open grate"]:{"grate"};["at the top of the stairs"]:{"cage"};["in the bird chamber"]:{"bird"};["inside the building"]:{"keys"}} IN objects
  275. PUT "outside the building" IN place
  276. PUT {["at the open grate"]:{"grate"};["at the top of the stairs"]:{"cage"};["in the bird chamber"]:{"bird"};["inside the building"]:{"keys"}} IN start.objects
  277. PUT {["down"]:{"d"};["east"]:{"e"};["in"]:{"enter"};["look"]:{"where"};["move"]:{"go"; "run"; "walk"};["north"]:{"n"};["out"]:{"exit"; "leave"};["south"]:{"s"};["up"]:{"u"};["west"]:{"w"}} IN synonyms
  278. PUT {"outside the building"} IN visited
  279.